<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style" />
		<meta content="telephone=no" name="format-detection" />
		<meta content="email=no" name="format-detection" />
		<title>传感数据-从数据库查询</title>
		<link rel="stylesheet" href="../../css/s_plus.css" />
		<!--<link rel="stylesheet" href="../../css/mui.min.css" />-->

		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/layout.css" />
		<link rel="stylesheet" href="../../css/choice.css" />
		<script type="text/javascript" src="../../libs/vue.js"></script>
		<script type="text/javascript" src="../../js/jquery.1.9.1.min.js"></script>
		<script type="text/javascript" src="../../js/app/url.js"></script>
		<script type="text/javascript" src="../../libs/hui.js"></script>
		<script type="text/javascript" src="../../js/s_plus.js"></script>
		<script type="text/javascript" src="../../js/md5.js"></script>
		<script type="text/javascript" src="../../js/app/api.js"></script>
		<script type="text/javascript" src="../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../js/app/ble.js"></script>

	</head>

	<body class="bg_gray">
		<div id="app">
			<header class="f_l maxbox subhead">
				<a class="back" @click="back"><i class="iconfont">&#xe605;</i></a>
				<!--<input type="hidden" value="{{sensor.NUMBER}}" />-->
				<h1>传感数据 </h1>
			</header>
			<section class="f_l maxbox sensor_data">
				<ul>

					<li v-for="item in sensorList">
						<b>{{item.title}}</b>
						<span>{{item.content}} </span>
					</li>
					<!--<li>
						<b>NB卡信号值</b>
						<span>{{nb.xinhao}} </span>
					</li>
					<li>
						<b>NB卡号</b>
						<span>{{nb.card}}   </span>
					</li>
					<li>
						<b>电池电压值</b>
						<span>{{status.dy}} </span>
					</li>
					<li>
						<b>井盖是否破损</b>
						<span>{{status.jgwps}}</span>
					</li>

					<li>
						<b>底部是否开启</b>
						<span>{{status.db}}</span>
					</li>
					<li>
						<b>中部是否开启</b>
						<span>{{status.zb}}</span>
					</li>
					<li>
						<b>顶部是否开启</b>
						<span>{{status.dingb}}</span>
					</li>-->

				</ul>

				<!--<div><button>报装</button></div>-->

			</section>

			<section class="f_l maxbox mar_t mar_f t_c" v-if="type =='baozhuang'">
				<a class="btn mian_btn" @click="shezhi">设置</a>&nbsp;&nbsp;&nbsp;
				<a class="btn mian_btn" @click="baozhuang">报装</a>
				<p>&nbsp;</p>
			</section>
		</div>
		<script>
			var sp = new Vue({
				el: "#app",
				data: {
					sensorList: [],
					Tid: "",
					status: {
						dy: "",
						jgwps: "",
						db: "",
						zb: "",
						dingb: ""
					},
					nb: {
						xinhao: "",
						card: ""
					},
					sensor: {},
					type: "",
					eventId: ""
				},
				mounted: function() {
					var eventId = localStorage.getItem("eventId");

					var type = localStorage.getItem("type");
					this.type = type;
					console.log("this.eventId---" + eventId);
					this.eventId = eventId;

					this.loadData();
					//		getNB();

				},
				methods: {

					loadData: function() {
						var path = urlManager.sensorData() + "?eventid=" + this.eventId;
						console.log(path);
						var username = localStorage.getItem("username");
						var sec = localStorage.getItem("sec_pwd");
						var time = apiManage.getNow();
						var key = "loginName=" + username + "&passWord=" + sec + "&time=" + time;
						console.log(key);
						var paramKey = hex_md5(key);

						$.ajax({
							type: "GET",
							url: path,
							beforeSend: function(request) {
								request.setRequestHeader("loginName", username);
								request.setRequestHeader("time", time);
								request.setRequestHeader("sign", paramKey);

							},
							success: function(result) {

								console.log("获取传感数据============================" + JSON.stringify(result));
								
								if(result.RSSI==null||result.RSSI==''){
									hui.toast("暂无数据");
									return;
								}
								
								var sensorData = [];

								for(var prop in result) {
									//输出 key-value值
									sensorData.push({
										title: prop,
										content: result[prop]
									});

//									console.log("jsonObj[" + prop + "]=" + result[prop]);
								}
								console.log("--------" + JSON.stringify(sensorData));
								sp.sensorList = sensorData;

							}
						});

					},

					shezhi: function() {
						localStorage.setItem("nosubmit", "no");

						var zdCode = localStorage.getItem("pid");

						localStorage.setItem("Tid", zdCode);
						localStorage.setItem("zd_id", zdCode);

						hui.open("/modules/terminal/setting.html?time=" + apiManage.getNow(), {}, true, {
							Tid: zdCode
						});

					},
					baozhuang: function() {
						var zdCode = localStorage.getItem("pid")
						localStorage.setItem("Tid", zdCode);
						//							hui.open("/modules/alerm/sensor_data.html?time"+apiManage.getNow(), {}, true, {});	
						hui.open("/modules/terminal/expand.html?s=" + apiManage.getNow(), {}, true, {});
					},
					showBroke: function(param) {
						if(param == null || param == '') {
							return "";
						}
						if(param == '1') {
							return "破损";
						} else {
							return "未破损";

						}
					},
					showStatus: function(param) {
						if(param == null || param == '') {
							return "";
						}
						if(param == '1') {
							return "开启";
						} else {
							return "关闭";

						}
					},
					back: function() {
						localStorage.setItem("pid", "");
						localStorage.setItem("type", "");
						hui.back();
					},
					chuangan: function() {
						var workId = this.zd.workId;
						localStorage.setItem("workId", workId);
						hui.open("work_show.html", {}, true, {});
					}

				}

			});
		</script>
	</body>

</html>